class User < ActiveRecord::Base
  has_many :posts, :order => 'created_at DESC'
  has_many :comments

  validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
  validates_uniqueness_of :email

  def display_name
    return "#{first_name} #{last_name}"
  end

  def latest_post
    return self.posts.first
  end
end